package com.jack.payment.aspect;


import com.jack.payment.entity.common.CommonResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    private Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);

    /**
     * 前端传值验证
     * @param e
     * @return
     */
    @ExceptionHandler(BindException.class)
    public CommonResult bindException(BindException e) {
        return CommonResult.error(-400, e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
    }
}
